﻿
angular.module('SLG')
  .controller("loadingKingdomController", function ($scope, $state, $rootScope, $http) {

    function getKingdom() {
        var url = "../../Api.ashx?sys:sno=Kingdom&sys:act=Get";
        var defer = Q.defer();

        $http.get(url).success(function (data) {
  	        defer.resolve({ data: data });
        })

        return defer.promise;
    }

  	function getCityList() {
  	    var url = "../../Api.ashx?sys:sno=City&sys:act=GetList";
  	    var defer = Q.defer();

  	    $http.get(url).success(function (data) {
  	        defer.resolve({ data: data });
  	    })

  	    return defer.promise;
  	}

  	var promise = getKingdom();
  	promise.then(function (data) {
  	    if (data.data.IsSuccess) {
		    $state.go("home");
		}
            //对象不存在，跳转到选择种族页面--->创建国王
  		else {
		    $state.go("createKingdom");
  		}
  	})

  })